package zzzhc.image.ui;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class PanelLauncher {

	private JPanel panel;

	private JFrame frame;

	public PanelLauncher(JPanel panel) {
		this.panel = panel;
	}

	public void show(int w, int h) {
		if (frame == null) {
			frame = new JFrame("Panle launcher");
			Container content = frame.getContentPane();
			content.setLayout(new BorderLayout());
			content.add(panel, BorderLayout.CENTER);
			frame.setSize(w, h);
			Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
			frame.setLocation((dim.width - w) / 2, (dim.height - h) / 2);
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			frame.setVisible(true);
		}
	}

}
